<?php session_start();?>
<!doctype html>
<html>
  <head>
  <link rel="icon" 
      type="image/png" 
      href="../favicon.png">
  <title>print</title>
  	<meta http-equiv="content-type" content=""text/htm; charset=UTF-8" >
	<link href="print.css" rel="stylesheet" type="text/css">
    
  	
  	
  	
  	
  
    <script type="text/javascript">
     
    </script>
  </head>
  <body>
<?php

require '../nette/Nette/loader.php';
require '../db.php';
require '../localization/lang.php';
require '../core/core.sanitizer.php';
require '../core/core.security.php';
require '../core/core.dfs.php';
require '../visual/visual.dfs.php';
require '../core/core.time.php';
require '../core/core.statistics.php';

$login=new core_security;
if ($login->checklogin()=="OK" AND $_SESSION['role']<=2) {
$loc=new loc;
$datetime=new core_time;
$datefrom=explode("/",$_GET['datefrom']);
$datetime->date=$datefrom[1].":".$datefrom[0].":".$datefrom[2];
$datetime->time="00:01";
//$from=$datetime->totimestamp();
$from=strtotime($_GET['datefrom']." 00:00:01");
$dayfrom=strtotime($_GET['datefrom']);
$dateto=explode("/",$_GET['dateto']);
$dayto=strtotime($_GET['dateto']);
$datetime->date=$dateto[1].":".$dateto[0].":".$dateto[2];
$datetime->time="23:59";
//$to=$datetime->totimestamp();
$to=strtotime($_GET['dateto']." 23:59:59");
$statist=new core_statistics($_GET['datefrom'],$_GET['dateto']);


/**
$users="";
$query="select * from users WHERE disabled != 1";
$result=mysql_query($query);
if ($_GET['datefrom'] != "" AND $_GET['dateto'] != "") {
echo "<b>".$loc->attendancefor.$_GET['datefrom']." - ".$_GET['dateto']."</b><br>";
echo "<div class='maindiv'id='attendanceshow'><table>";
echo "<tr ><th class='statsheader'>".$loc->user."</th><th class='statsheader'>".$loc->attendancefromattendance."</th><th class='statsheader'>".$loc->attendancefromworkload."</th></tr>";
while ($row=mysql_fetch_array($result)) {
	$query2="select sum(att) as attend from attendance where day >= ".$dayfrom." AND day <= ".$dayto." AND uid = ".$row['id']."";
	$statist->uid=$row['id'];
	$result2=mysql_query($query2);
	$row2=mysql_fetch_array($result2);
	$attendfromwork=$statist->return_total();
	if ($attendfromwork=="") {$attendfromwork=0;}
	if ($row2['attend']== $attendfromwork) { $trclass="statsok";} else { $trclass="statsfail";}
	echo "<tr class='".$trclass."' onClick='attend_details(\"".$row['id']."\",\"".$_GET['datefrom']."\",\"".$_GET['dateto']."\");'><td class='stats'>".$row['name']."</td><td class='stats'>".$datetime->tohm($row2['attend'])."</td><td>".$datetime->tohm($attendfromwork)."</td></tr>";
	}


}
echo "</table></div>";
}
**/
$showdate=strtotime($_GET['datefrom']);
$userquery="select name from users where id=".$_GET['userid'];
$userresult=mysql_query($userquery);
$userrow=mysql_fetch_array($userresult);

echo "<b class='breaker'>".$loc->daybydayattendanceforuser.$userrow['name']."<br>".$_GET['datefrom']." - ".$_GET['dateto']."</b><br>";
for ($i=$showdate;$i<$to;$i=$i+86400) {
//	echo "<br>".$i;
	echo "<div class='nobreaker'>";
	echo "<br><b class='breaker'>".date('m/d/Y',$i)."<b>";
	echo "<table class='daybydaytable'>";
	echo "<tr ><th class='statsheader'>from</th><th class='statsheader'>to</th><th class='statsheader'>job</th><th class='statsheader'>note</th></tr>";
	$morning=strtotime(date('m/d/y',$i)." 00:00:01");
	$evening=strtotime(date('m/d/y',$i)." 23:59:59");
	$query="select * from userjobs WHERE from_ > ".$morning." and to_ < ".$evening." AND uid= ".$_GET['userid']." ORDER BY from_";
	$result=mysql_query($query);
	if ($result) {
	while($row=mysql_fetch_array($result)) {
		echo "<tr>";
		echo "<td>".date('H:i',$row['from_'])."</td>";
		echo "<td>".date('H:i',$row['to_'])."</td>";
		echo "<td>".$row['jdesc']."</td>";
		echo "<td>".$row['note']."</td>";
		echo "</tr>";
		}
 
	
	}
	echo "</table></div>";
	//echo $query;
	//echo $morning." ".$evening;
	}
/**if ($_GET['datefrom'] != "" AND $_GET['dateto'] != "" AND $_GET['userid'] != "") {

echo "<b>".$loc->daybydayattendanceforuser.$_GET['username']."<br>".$_GET['datefrom']." - ".$_GET['dateto']."</b><br>";

echo "<div class='maindiv'id='attendanceshow'><table>";
echo "<tr ><th class='statsheader'>".$loc->user."</th><th class='statsheader'>from</th><th class='statsheader'>to</th><th class='statsheader'>job</th><th class='statsheader'>note</th></tr>";


echo "</table></div>";
**/
}
?>
<script>
javascript:window.print();
</script>
</body>
</html>
